package com.gym.core.threadpool;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 
 * 
 * 
  private final int TIME_THREADS = 50;
  private ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(TIME_THREADS);
  private void scheduleAtFixedRate( Class<? extends Runnable> taskClazz, long initialDelay, long period, TimeUnit unit) {
	        this.scheduledExecutorService.scheduleAtFixedRate(new TaskWrapper(taskClazz), initialDelay, period, unit);
	    }
 * 
 * @author xinchun.wang 
   @email: 532002108@qq.com
 * @createTime 2015-3-2 下午2:36:50
 */
public class TaskWrapper  implements Runnable{
	 public static Logger logger = LoggerFactory.getLogger(TaskWrapper.class);
	 
	    private Class<? extends Runnable> type;
	 
	    public TaskWrapper(Class<? extends Runnable> clazz) {
	        this.type = clazz;
	    }
	 
	    @Override
	    public void run() {
	 
	        Runnable task = null;
	        try {
	            task = this.type.newInstance();
	            task.run();
	        } catch (Throwable e) {
	            	 logger.error(" ERROR", e);
	        }finally {
	        	//TODO
	        }
	 
	    }

}
